<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/dtree.css">
    <link rel="stylesheet" th:href="@{/}+'layuiadmin/plugins/dtree/dtree/font/dtreefont.css'">
    <style>
        .dtree-select-show {
            z-index: 9999;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" lay-filter="myform" id="myform">
                    <div class="layui-form-item">
                    	<label class="layui-form-label">会议地点</label>
				        <div class="layui-input-inline" style="width:200px!important">
				            <input type="text" name="placeName" id="placeName" autocomplete="off" class="layui-input">
				            <input type="hidden" name="placeId" id="placeId">
				        </div>
                    	<label class="layui-form-label">审核状态</label>
				        <div class="layui-input-inline">
				            <select name="state" id="state"></select>
				        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">会议主题</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">会议日期</label>
                            <div class="layui-input-inline">
                                <input type="text" name="meetingDate" id="meetingDate"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        
                        <div class="layui-inline">
                            <div class="layui-btn-group">
                                <input type="reset" id="btReset" class="layui-hide" >
                                <button type="button" class="layui-btn " data-type="query"><i class="layui-icon">&#xe615;</i>查询</button>
                                <button type="button" class="layui-btn " data-type="resetBtn"><i class="layui-icon">&#xe669;</i>重置</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="layui-hide"  id="main-table" lay-filter="main-table"></table>
            </div>
        </div>
    </div>
</div>

<script th:inline="none"></script>

<script>
layui.link('layuiadmin/plugins/layui_complete-master/autocomplete.css'); 
layui.extend({
	autocomplete: '{/}layuiadmin/plugins/layui_complete-master/autocomplete' 
});

    layui.extend({
        tableSelect: '{/}layuiadmin/plugins/tableSelect' 
    });
    layui.extend({
        dtree: '{/}layuiadmin/plugins/dtree/dist/dtree' 
    });
    layui.use(['table','form','tableSelect','dtree','autocomplete','laydate'], function(){
        var table = layui.table,
            form = layui.form
            laydate = layui.laydate
            autocomplete = layui.autocomplete
            ,tableSelect = layui.tableSelect
            ,dtree = layui.dtree;
        table.render({
            elem: '#main-table'
            ,height: (top.height-85)+'px'
            ,url: 'appVersion/getPageList'
            ,title: '版本列表'
            ,page: true 
            ,limit:16
            ,toolbar: '#toolbar' 
            ,cols: [
                [ 
                {type: 'checkbox'}
                ,{type: 'numbers'}
                ,{field: 'versionName', title: "版本名称",width:150,templet:function(d){
                	return "<a class='colum-link' href='javascript:void(0)' onclick='edit(\""+d.id+"\",this)'>" + d.versionName + "</a>";
                }}
                ,{field: 'versionCode',title: "版本编号",width:110}
                ,{field: 'createTime',title: "上传时间",width:170}
                ,{field: 'styleTxt',title: "版本风格",width:150}
                ,{field: 'repoName',title: "存储名称",width:210}
                ,{field: 'expression',title: "更新说明"}
            ]
            ]
            ,done:function(){
          	  enableRowClick(table,form,'main-table',"main-table");
             }
        });
        //头工具栏事件
        table.on('toolbar(main-table)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            switch(obj.event){
                case 'add':
                    top.layer.open({
                        id:"openwin",
                        type: 2,
                        title:'增加版本',
                        area:['1240px','700px'],
                        content:  'rooter?url=system/app/add-app',
                        btn:['保存','关闭'],
                        yes:function(index,layero){
                            var dataForm = top.layer.getChildFrame('form', index);
                            dataForm.find("#submitBtn").click();
                            return false
                        }
                    });
                    break;
                case 'delete':
                    var data = checkStatus.data;
                    if(data.length>0){
                        var values = {};
                        var ids=[];
                        $.each(data,function(i,v){
                            ids.push(v.id);
                        })
                        values['ids'] = ids;
                        layer.confirm('确定要删除当前行么?', {icon: 3, title:'提示'}, function(index){
                        	$.post("appVersion/delete",values,function(res){
                        		if (res.code == 1) {
                                    layer.msg(res.msg);
                                } else {
                                    layer.close(index);
                                    table.reload('main-table');
                                }
                        	})
                        });
                    }else{
                        layer.msg("请选择操作数据!")
                    }
                    break;
            };
        });
        var $ = layui.$, active = {
            query: function(){

                table.reload("main-table",{where:{name:$("#name").val()
                	,placeId:$("#placeId").val()
                	,state:$("#state").val()
                	,meetingDate :$("#meetingDate").val()
                	}})
            },
            resetBtn:function () {
                $("#btReset").click();
                
            }
        };
        window.loadGrid = function(tableName){
            table.reload(tableName);
        }
        $('.layui-form .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
    function edit(id){
    	top.layer.open({
            id:"openwin",
            type: 2,
            title:'修改版本信息',
            area:['1240px','700px'],
            content:  'rooter?url=system/app/add-app&id='+id,
            btn: ['保存','关闭'],
            yes: function(index,layero){
            	var dataForm = top.layer.getChildFrame('form', index);
                dataForm.find("#submitBtn").click();
                return false
            }
        });
    }
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-addition"></i>增加</button>
        <button class="layui-btn layui-btn-sm" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
    </div>
</script>
</body>
</html>